import axios from '@/utils/axios.js'

// export const getAllUsers = (params) => {
//   return axios({
//     url: 'users',
//     params
//   })
// }
// 获取所有用户
export const getAllUsers = (params) => {
  return axios({
    url: 'users',
    params
  })
}
// 增加用户
export const addUsers = (data) => {
  return axios({
    url: 'users',
    method: 'post',
    data
  })
}

// // 通过id获取对应的用户

// export const editUserById = (data) => {
//   return axios({
//     url: `users/:${data.id}`,
//     method: 'get'
//   })
// }
// 实现编辑用户数据
export const editUserById = (data) => {
  return axios({
    url: `users/${data.id}`,
    method: 'put',
    data
    // : { email: data.email, mobile: data.mobile }
  })
}

// 删除用户

export const deltUserById = (id) => {
  return axios({
    url: `users/${id}`,
    method: 'delete'
  })
}
// 修改用户状态
export const editUserstatus = (uid, type) => {
  return axios({
    url: `users/${uid}/state/${type}`,
    method: 'put'
  })
}

// 修改角色分配
export const grantUserRole = (data) => {
  return axios({
    url: `users/${data.id}/role`,
    method: 'put',
    data: { rid: data.rid }
  })
}
